//
//  ViewController.m
//  Tools
//
//  Created by 吴浪 on 16/3/10.
//  Copyright © 2016年 吴浪. All rights reserved.
//

#import "ViewController.h"
#import "AppDelegate.h"
//#import "UICopyLabel.h"
#import "HyperlinksButton.h"
#import "UIView+LYExt.h"
#import "UIImageView+LBBlurredImage.h"
#import "UIButton+LYExt.h"
#import "LYCountDownButton.h"


@protocol ViewDelegate <NSObject>


@end
@interface ViewController ()<ViewDelegate> {
    UIScrollView *_scrollView;
}
@property (strong, nonatomic) UIImage *image; /**< 呵呵 */
@property (copy, nonatomic) NSString *str;
@property (strong, nonatomic) UIImage *name;
@property (weak, nonatomic) UIImage *na;

@property (weak, nonatomic) id<ViewDelegate> delegate;
@property (weak, nonatomic) id<ViewDelegate> delegdate;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    // Do any additional setup after loading the view, typically from a nib.
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30.0, 60.0, 300.0, 300.0)];
//    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.top = 60.0;
    scrollView.left = 30.0;
    scrollView.bottom = 360.0;
    scrollView.right = 330.0;
    scrollView.contentInset = UIEdgeInsetsMake(-60, 0, 0, 0);
    scrollView.backgroundColor = [UIColor greenColor];
    scrollView.contentSize = CGSizeMake(300.0 * 4, 300.0);

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300.0, 300.0)];

    imageView.image = [UIImage imageNamed:@"test1"];
    [imageView setImageToBlurCompletionBlock:NULL];
    
    [scrollView addSubview:imageView];
    [self.view addSubview:scrollView];
//
    HyperlinksButton *view = [[HyperlinksButton alloc] initWithFrame:CGRectMake(scrollView.frame.origin.x - 20.0, scrollView.frame.origin.y, 10.0, 300.0)];
    view.backgroundColor = [UIColor whiteColor];
    [view addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:view];
    
    HyperlinksButton *btn = [HyperlinksButton ly_ButtonWithNormalImageName:nil selecteImageName:nil target:nil selector:nil];
    btn.backgroundColor = [UIColor blueColor];
    btn.lineColor = [UIColor blackColor];
    [btn setTitle:@"是的" forState:UIControlStateNormal];
    btn.frame = CGRectMake(0, 400.0, 320.0, 40.0);
    [self.view addSubview:btn];
    _scrollView = scrollView;
    
    LYCountDownButton *btn1 = [LYCountDownButton countDownButton];
    btn1.frame = CGRectMake(0, 450.0, 320.0, 40.0);
    [btn1 startWithSecond:10];
//    [btn1 didChange:^NSString *(LYCountDownButton *countDownButton, int second) {
//        return [NSString stringWithFormat:@"%zd", second];
//    }];
    [self.view addSubview:btn1];
//
//    
////    UICopyLabel *label = [[UICopyLabel alloc] initWithFrame:CGRectMake(10.0, 260.0, 40.0, 50.0)];
////    label.backgroundColor = [UIColor redColor];
////    label.userInteractionEnabled = YES;
////    [self.view addSubview:label];
//    
//    UIButton *bty = [UIButton ly_buttonWithNormalImageName:@" " selecteImageName:@" " target:nil selector:nil];
}

- (void)click {
    NSInteger i = arc4random() % 2;
    [_scrollView scrollRectToVisible:CGRectMake(i * 240.0, 60.0, 240.0, 200.0) animated:YES];
    AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication];
//    [app app];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
